﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ue.Eagle.Runtime.Models
{
    public class PluginExtensionPoint
    {
        //private Func<string, IEnumerable<PluginExtension>> acquireExtensions;
        private string extensionElementType;

        //public PluginExtensionPoint(string id,string name,string extensionElementType,Func<string,IEnumerable<PluginExtension>> acquireExtensions)
        public PluginExtensionPoint(string id, string name, string extensionElementType)
        {
            this.Id = id;
            this.Name = name;
            //this.acquireExtensions = acquireExtensions;
            this.extensionElementType = extensionElementType;
        }

        /// <summary>
        /// 扩展点Id 
        /// Id格式： PluginId + "." + ExtensionPointName
        /// </summary>
        public string Id { get; private set; }

        /// <summary>
        /// 扩展点名称
        /// </summary>
        public string Name { get; private set; }

        //public IEnumerable<PluginExtension> PluginExtensions
        //{
        //    get { return this.acquireExtensions(this.Id); }
        //}

        /// <summary>
        /// 扩展节点类型
        /// </summary>
        internal Type ExtensionElementType
        {
            get
            {
                try
                {
                    return Type.GetType(this.extensionElementType);
                }
                catch
                {
                    return null;
                }
            }
        }
    }
}
